package cn.sundat.utils;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

public class FastJsonUtils {
	/**
	 * 将object转换为json数组
	 * @param object
	 * @return
	 */
	public static String toJsonString(Object object) {
		String jsonString = JSON.toJSONString(object);
		return jsonString;
	}
	
	/**
	 * 将json字符串转写出到浏览器
	 */
	public  static void  write_json(HttpServletResponse response,String jsonString) {
		response.setContentType("application/json;charset=utf-8");
		try {
			response.getWriter().print(jsonString);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
}
